package cn.vivi.util;

import java.util.HashMap;
import java.util.Map;

public class Result {

	private Boolean success;
	private String message;
	private Map<String, Object> data = new HashMap<>();

	private Result() {
	}

	public static Result success() {
		Result result = new Result();
		result.setSuccess(true);
		result.setMessage("success");
		return result;
	}

	public static Result error() {
		Result result = new Result();
		result.setSuccess(false);
		result.setMessage("error");
		return result;
	}

	public Result createMap() {
		return this.setData(new HashMap<String, Object>());
	}

	public Result setData(String key, Object value) {
		this.getData().put(key, value);
		return this;
	}

	public String getMessage() {
		return message;
	}

	public Result setMessage(String message) {
		this.message = message;
		return this;
	}

	@Deprecated
	public Map<String, Object> getData() {
		return data;
	}

	private Result setData(Map<String, Object> data) {
		this.data = data;
		return this;
	}

	@Deprecated
	public Boolean getSuccess() {
		return success;
	}

	private void setSuccess(Boolean success) {
		this.success = success;
	}

	@Override
	public String toString() {
		return "Result [success=" + success + ", message=" + message + ", data=" + data + "]";
	}

}
